﻿package com.winmastergames.decalsystem {
	import flash.display.BitmapData;
	import flash.net.URLRequest;
	import flash.display.Loader;
	import flash.system.LoaderContext;

	public class decalLoader {
		// TODO: Document This Class on Wiki.
		public static var bmd:BitmapData;
		public static function getRequest(assetLocation:String):URLRequest {
			var request:URLRequest = new URLRequest(assetLocation);
			return request;
		}

		public static function getLoader():Loader {
			return new Loader();
		}

		public static function loadAsset(assetLoader:Loader, assetRequest:URLRequest):void {
			var loaderContext:LoaderContext = new LoaderContext();
			loaderContext.checkPolicyFile = true;
			assetLoader.load(assetRequest, loaderContext);
		}

		public static function getFilename(input:String):String {
			var myPattern:RegExp = /\//g;
			var urlString:String = input;
			urlString = urlString.replace(myPattern, ":");
			var splitUrl:String = urlString.substr(urlString.lastIndexOf(":"), urlString.length - 1);
			splitUrl = splitUrl.replace(":", "");
			return splitUrl;
		}
		public static function getBitmapStage(width:int, height:int):BitmapData {
			bmd = new BitmapData(width, height);
			return bmd;
		}
	}
}